$(function () {
    $('#grid_bj').datagrid({
        url: $.webPath() + "/organ/gsjg/nbgsList",
        toolbar: '#toolbar_bj',
        fitColumns: true,
        fit: true,
        pageNumber: 1,
        checkbox: true,
        checkOnSelect: false,
        selectOnCheck: false,
        rownumbers: true,
        columns: [
            [
                {field: 'checked', checkbox: true},
                {field: 'qc', title: '公司名称', align: 'center', width: 150, formatter: formatName}
            ]
        ],
        onLoadSuccess:function(){
            $('#grid_bj').datagrid('checkRow',9);
            $('#grid_bj').datagrid('checkRow',6);
            $('#grid_bj').datagrid('checkRow',15);
            $('#grid_bj').datagrid('checkRow',2);
            $('#grid_bj').datagrid('checkRow',14);
        }
    });

    //新增触发
    $('#btn_bj_add').click(function () {
        var id = '';
        var rows = $("#grid_bj").datagrid('getChecked');
        if (rows.length <= 0)
            $.messager.alert('提示', "请选择报价公司", 'info');
        else {
            for (var i = 0; i < rows.length; i++) {
                id += rows[i].id + ',';
            }
            id=id.substring(0, id.length - 1);
            winopen($.webPath() + "/sys/bjgl/bjDetail?gsId=" + id);
        }
    });
})

function formatName(val, row) {
    return '<a href="javascript:viewCharge(\'' + row.id + '\');" style="color: red">' + val + '</a>';
}

function viewCharge(id) {
    winopen($.webPath() + "/sys/bjgl/bjDetail?gsId=" + id);
}

function winopen(targeturl) {
    var newwin = window.open(targeturl, "", "height=300, width=700, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=yes,location=no, status=no");
}